****** DO-FILE FOR DATA FROM NORDIC NOIR PROJECT ******
****** uses "merged_file_RS.dta" which has both Swedish and Danish sample ******

*** CHANGE NAME OF DATA
*** CROP DATA TO ONLY RELEVANT VARIABLES
**** CHANGE THIS AT LAST MINUTE ****

 use "defendingwhatnation.dta", clear

* recoding willingness to defend

gen willingness = Q18
recode willingness 4=1 3=2 2=3 1=4
tab willingness


* remove dont know and prefer not to answer

recode personal_income 12=. 13=.


* make labels
label variable educ_d "Education"
label variable proud_n "General national pride"
label variable attach_n "National attachment"
label variable ident_n "National identification"
label variable uncrit_n "Uncritical patriotism"
label variable narcis_n "Collective narcissism"
label variable chauv_n "National chauvinism"
label variable civic_n "Civic conception"
label variable cultural_n "Cultural conception"
label variable ethno_n "Ethnic conception"
label variable Q10_1 "the way democracy works"
label variable Q10_2 "political influence in the world"
label variable Q10_3 "level of economic development"
label variable Q10_4 "welfare system"
label variable Q10_5 "scientific and technical achievements"
label variable Q10_6 "sporting achievements"
label variable Q10_7 "art and literature"
label variable Q10_8 "Military pride"
label variable Q10_9 "history"
label variable Q10_10 "fair and equal treatment"
label variable Q3_1 "Left-right placement"
label variable age "Age"



********** SWEDEN ONLY ACTIVATED BELOW ****************

drop if ID==1



*** BASE MODELS ***

* base control variable model

ologit willingness age Q3_1 gender urban i.personal_income i.educ_d


*collinearity diagnostics
*Model 1
regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 i.personal_income i.educ_d

vif

*Model 3
regress willingness civic_n ethno_n cultural_n age gender urban Q3_1 civic_n ethno_n cultural_n i.personal_income i.educ_d

vif

*** MODEL 2 BELOW, WHEN FACTOR VARIABLES HAVE BEEN CREATED ***


* national identity variables cluster 1*

ologit willingness ident_n attach_n proud_n chauv_n uncrit_n narcis_n age gender Q3_1 urban  i.personal_income i.educ_d

estimates store Model1

*produce Figure 1
coefplot Model1, bylabel(M1 (controls))  ///
       ||, drop(_cons) xline(0) graphregion(color(white)) ciopts(color(black))


* produce table A.1for appendix	
	esttab Model1 using Model1.doc, replace ///
    se stats(r2_p ll) starlevels(* 0.10 ** 0.05 *** 0.01)
	   
*** simulations; in OLS

** first, replicate with OLS ***
* replicates for the IDVs

regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1  i.personal_income i.educ_d

*** Simulation ***

estsimp regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 personal_income educ_d

* willingness: 3.38
setx mean
simqi

* willingness: 3.45
setx proud_n 
simqi
'
* willingness: 3.24
setx proud_n 0
simqi


drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14

estsimp regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 personal_income educ_d

* willingness: 3.38
setx mean
simqi

* willingness: 3.45
setx attach_n 1
simqi

* willingness: 3.19
setx attach_n 0
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14



estsimp regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 personal_income educ_d

* willingness: 3.38
setx mean
simqi

*willingness: 3.4
setx ident_n 1
simqi

* willingness: 3.23
setx ident_n 0
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14



estsimp regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 personal_income educ_d

* willingness: 3.38
setx mean
simqi

* willingness: 3.2
setx uncrit_n 1
simqi

* willingness: 3.48
setx uncrit_n 0
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14


estsimp regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 personal_income educ_d

* willingness: 3.38
setx mean
simqi

* willingness: 3.54
setx chauv_n 1
simqi

* willingness: 3.19
setx chauv_n 0
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14

estsimp regress willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 personal_income educ_d

* willingness: 3.38
setx mean
simqi

* willingness: 3.43
setx proud_n 1
setx attach_n 1
setx ident_n 1
simqi

* willingness: 2.89
setx proud_n 0
setx attach_n 0
setx ident_n 0
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14



*** national identity variables Cluster 2 ***

recode Q10_1 5=1 4=2 3=3 2=4 1=5
recode Q10_2 5=1 4=2 3=3 2=4 1=5
recode Q10_3 5=1 4=2 3=3 2=4 1=5
recode Q10_4 5=1 4=2 3=3 2=4 1=5
recode Q10_5 5=1 4=2 3=3 2=4 1=5
recode Q10_6 5=1 4=2 3=3 2=4 1=5
recode Q10_7 5=1 4=2 3=3 2=4 1=5
recode Q10_8 5=1 4=2 3=3 2=4 1=5
recode Q10_9 5=1 4=2 3=3 2=4 1=5
recode Q10_10 5=1 4=2 3=3 2=4 1=5

*** factor analysis of contents ***
* no good loading för Q10_8
corr Q10_1 Q10_2 Q10_3 Q10_4 Q10_5 Q10_6 Q10_7 Q10_8 Q10_9 Q10_10


*factor Q10_1 Q10_2 Q10_3 Q10_4 Q10_5 Q10_6 Q10_7 Q10_8 Q10_9 Q10_10
*	rotate 

*scree	
		
* Model applied in paper 

factor Q10_1 Q10_2 Q10_3 Q10_4 Q10_5 Q10_6 Q10_7 Q10_9 Q10_10
	rotate 

scree
	
	predict factor1 factor2
	
	label variable factor1 "Civic pride"
	label variable factor2 "Cultural pride"
	

corr factor1 factor2 Q10_8
  
** Model 2 national identity cluster 2**

* collineratity diagnostics
regress willingness  factor1 factor2 Q10_8 age gender urban Q3_1 i.personal_income i.educ_d

vif

* Model 2
ologit willingness factor1 factor2 Q10_8 age gender urban Q3_1 i.personal_income i.educ_d

estimates store Model2

* produce Figure 2

coefplot Model2, bylabel(M1 (controls))  ///
       ||, drop(_cons) xline(0) graphregion(color(white)) ciopts(color(black))
	   
* produce table for Model2 in the appendix

esttab Model2 using Model2.doc, replace ///
    se stats(r2_p ll) starlevels(* 0.10 ** 0.05 *** 0.01)

* simulations
* replicate in OLS; replicates
	   
regress willingness factor1 factor2 Q10_8 age gender urban Q3_1 personal_income educ_d

*varying factor2
* factor2 simulations have stronger effect than q10_8
* mean 3.37
* min 2.94
* max 3.6

estsimp regress willingness factor1 factor2 Q10_8 age gender urban Q3_1 personal_income educ_d

* willingness: 3.37
setx mean
simqi

* willingness: 3.00
setx factor2 -2.9
simqi

* willingness: 3.59
setx factor2 1.79
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11

*varying Q10_8
*mean 3.37
* min 3.21
* max 3.5

estsimp regress willingness factor1 factor2 Q10_8 age gender urban Q3_1 personal_income educ_d

setx mean
simqi

setx Q10_8 1
simqi

setx Q10_8 5
simqi


drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11

* varying factor1
* mean: 3.37
* min 3.26
* max 3.46

estsimp regress willingness factor1 factor2 Q10_8 age gender urban Q3_1 personal_income educ_d

setx mean
simqi

setx factor1 -2.3
simqi

setx factor1 2.03
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11



* national identity variables cluster 3


ologit willingness civic_n ethno_n cultural_n age gender urban Q3_1 i.personal_income i.educ_d

estimates store Model3

* produce Figure 3

coefplot Model3, bylabel(M1 (controls))  ///
       ||, drop(_cons) xline(0) graphregion(color(white)) ciopts(color(black))

* produce table for Model2 in the appendix

esttab Model3 using Model3.doc, replace ///
    se stats(r2_p ll) starlevels(* 0.10 ** 0.05 *** 0.01)

*** simulations ***
** replicate in OLS
regress willingness civic_n ethno_n cultural_n age gender urban Q3_1 personal_income educ_d


* simulation *
estsimp regress willingness civic_n ethno_n cultural_n age gender urban Q3_1 personal_income educ_d

* mean 3.37
* min 2.97
* max 3.43

setx mean
simqi

setx civic_n 0
simqi

setx civic_n 1
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11




estsimp regress willingness civic_n ethno_n cultural_n age gender urban Q3_1 personal_income educ_d

* mean 3.37
* min 3.06
* max 3.51

setx mean
simqi

setx cultural_n 0
simqi

setx cultural_n 1
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11



estsimp regress willingness civic_n ethno_n cultural_n age gender urban Q3_1 personal_income educ_d

* mean: 3.37
* min 2.66
* max 3.56

setx cultural_n 0
setx civic_n 0
simqi

setx cultural_n 1
setx civic_n 1
simqi

drop b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11



 * Descriptive stats table
 
 
asdoc tabstat willingness age gender urban Q3_1 educ_d personal_income ident_n proud_n attach_n chauv_n uncrit_n narcis_n civic_n ethno_n cultural_n factor1 factor2 Q10_8,  stat(mean sd min max) columns(statistics)





	
********** DENMARK ONLY ACTIVATED BELOW, FOR REPLICATION ****************
* load data*


 use "defendingwhatnation.dta", clear

drop if ID==0

* recoding willingness to defend

gen willingness = Q18
recode willingness 4=1 3=2 2=3 1=4
tab willingness


* remove dont know and prefer not to answer

recode personal_income 12=. 13=.

* make labels
label variable educ_d "education"
label variable proud_n "general pride"
label variable attach_n "attachment"
label variable ident_n "identity"
label variable uncrit_n "uncritical"
label variable narcis_n "narcissism"
label variable chauv_n "chauvinism"
label variable civic_n "civic"
label variable cultural_n "cultural"
label variable ethno_n "ethnic"
label variable Q10_1 "the way democracy works"
label variable Q10_2 "political influence in the world"
label variable Q10_3 "level of economic development"
label variable Q10_4 "welfare system"
label variable Q10_5 "scientific and technical achievements"
label variable Q10_6 "sporting achievements"
label variable Q10_7 "art and literature"
label variable Q10_8 "military defense"
label variable Q10_9 "history"
label variable Q10_10 "fair and equal treatment"
label variable Q3_1 "left-right placement"

* national identity variables cluster 1*

*Model 4

ologit willingness proud_n attach_n ident_n uncrit_n narcis_n chauv_n age gender urban Q3_1 i.personal_income i.educ_d

estimates store Model4

* national identity variables cluster 2

factor Q10_1 Q10_2 Q10_3 Q10_4 Q10_5 Q10_6 Q10_7 Q10_9 Q10_10
	rotate 

scree
	
	predict factor1 factor2
	
	label variable factor1 "Civic pride"
	label variable factor2 "Cultural pride"
	
corr factor1 factor2 Q10_8


** Model 5

ologit willingness factor1 factor2 Q10_8 age gender urban Q3_1 i.personal_income i.educ_d

estimates store Model5

* Model 6

* national identity variables cluster 3 *t

ologit willingness civic_n ethno_n cultural_n age gender urban Q3_1 i.personal_income i.educ_d

estimates store Model6




